<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="https://unpkg.com/vue/dist/vue.js"></script>
</head>
<body>
    <div id="app">
        <component :is="currentView"></component>
        <button @click="handleChangeView('A')">A</button>
        <button @click="handleChangeView('B')">B</button>
        <button @click="handleChangeView('C')">C</button>
    </div>
</body>
</html>
<script>
    var app = new Vue({
        el: '#app',
        components:{
            comA: {
                template: `
                    <div>组件A</div>
                `
            },
            comB: {
                template: `
                    <div>组件B</div>
                `
            },
            comC: {
                template: `
                    <div>组件C</div>
                `
            }
        },
        data: {
            currentView: 'comA'
        },
        methods: {
            handleChangeView(c) {
                this.currentView = "com" + c
            }
        }
    })
</script>
